//
//  FileTools.m
//  DownDemo
//
//  Created by 喂！ on 2018/11/8.
//  Copyright © 2018年 well. All rights reserved.
//

#import "FileTools.h"

@implementation FileTools


+(NSString *)getModelFileAddress:(NSInteger)project WithType:(NSInteger)type
{
    NSFileManager *fileManager = [NSFileManager defaultManager];
    
    NSString *str = @"";
    
    if (type == 1) {
        str = [NSString stringWithFormat:@"ProjectFiles/Models/%@",[NSNumber numberWithInteger:project]];
    }
    else if(type == 2)
    {
        str = [NSString stringWithFormat:@"ProjectFiles/Pictures/%@",[NSNumber numberWithInteger:project]];
    }
    else if (type == 3)
    {
        str = @"SkinFile";
    }
    else
    {
        str = @"ProjectFiles/Models";
    }
    
    NSString *newPath = [[MainConfig sharedInstance].homeDir stringByAppendingPathComponent:str];
    if(![fileManager fileExistsAtPath:newPath])
    {
        [fileManager createDirectoryAtPath:newPath withIntermediateDirectories:YES attributes:nil error:nil];
    }
    return newPath;
}

#pragma mark - 解压压缩包
+(BOOL)unzipFile:(NSDictionary *)dic
{
//    NSString *filePath = [dic valueForKey:@"ZipAddress"];
//    NSString *folderPath = [dic valueForKey:@"TargetAddress"];
//
//    ZipArchive* zip = [[ZipArchive alloc] init];
//
//    NSFileManager *fileManager = [NSFileManager defaultManager];
//
//    if(![fileManager fileExistsAtPath:folderPath])
//    {
//        [fileManager createDirectoryAtPath:folderPath withIntermediateDirectories:YES attributes:nil error:nil];
//    }
//
//    if( [zip UnzipOpenFile:filePath] )
//    {
//        BOOL ret = [zip UnzipFileTo:folderPath overWrite:YES];
//        if( NO==ret )
//        {
//            return false;
//        }
//        [zip UnzipCloseFile];
//    }
//
//    [fileManager removeItemAtPath:filePath error:nil];
    
    return true;
}


@end
